package com.zxy.supplier_system.server.repository

import com.zxy.supplier_system.server.entity.Authority
import com.zxy.supplier_system.server.entity.Role
import com.zxy.supplier_system.server.entity.SystemService
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Modifying
import org.springframework.data.jpa.repository.Query

interface RoleRepository :JpaRepository<Role,String>{

    fun existsByNameAndSystemService(name: String, systemService: SystemService):Boolean

    fun findByNameAndSystemService(name: String, systemService: SystemService):Role?

    fun deleteByNameAndSystemService(name: String, systemService: SystemService)

    fun findAllBySystemService(systemService: SystemService):List<Role>

    @Query("update Role set authorities = ?1 where id =?2")
    @Modifying
    fun updateRoleAuthorities(authorities:List<Authority>,id:Int)



}